local skel = fk.CreateSkill {
  name = "lb__quantao",
  --tags = { Skill.Compulsory, }
}

Fk:loadTranslationTable {
  ["lb__quantao"] = "圈套",
  --[":lb__quantao"] = "<b>锁定技</b>，每名角色限一次，摸牌阶段，若你有手牌，你放弃摸牌并与一名角色拼点，若你赢，你摸点数差值张牌（至多为5）；若你没赢，你回复1点体力。",
  --9.23
  [":lb__quantao"] = "每名角色限一次，摸牌阶段，若你有手牌，你可以放弃摸牌并与一名角色拼点，若你赢，你摸点数差值张牌（至多为5）；若你没赢，你回复1点体力。",

  ["#lb__quantao"] = "圈套：你可以放弃摸牌并与一名角色拼点，若你赢，你摸点数差值张牌（至多为5），若你没赢，你回复1点体力",

  ["@[player]lb__quantao"] = "圈套",

  ["$lb__quantao1"] = "不冒点风险，又怎么尝得到甜头？",
  ["$lb__quantao2"] = "又有生意上门了。",
  ["$lb__quantao3"] = "我坚信，人与人之间美好的感情都是聊出来的。",
}

skel:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Draw
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local t = table.filter(room:getOtherPlayers(player), function(p)
      return player:canPindian(p) and not table.contains(player:getTableMark("@[player]lb__quantao"), p.id)
    end)
    if #t > 0 then
      local tos = room:askToChoosePlayers(player, {
        targets = t,
        min_num = 1,
        max_num = 1,
        prompt = "#lb__quantao",
        skill_name = skel.name,
        cancelable = true,
      })
      event:setCostData(self, { tos = tos })
      return #tos > 0
    end
  end,
  on_use = function(self, event, target, player, data)
    data.phase_end = true
    local room = player.room
    local p = event:getCostData(self).tos[1]
    local pindian = player:pindian({ p }, skel.name)
    if pindian.results[p].winner == player then
      local n = math.min((pindian.fromCard.number - pindian.results[p].toCard.number), 5)
      if n > 0 then
        room:drawCards(player, n, skel.name)
      end
    else
      room:recover({ who = player, num = 1, skillName = skel.name, recoverBy = player })
    end
    room:addTableMark(player, "@[player]lb__quantao", p.id)
  end,
})

return skel
